/*
 *  Copyright (C) 2010 Fabien Renaud
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.boc.botv.dao.impl;

import com.boc.botv.common.Database;
import com.boc.botv.dao.PaymentMethodDao;
import com.boc.botv.model.PaymentMethod;
import java.util.List;
import org.springframework.stereotype.Repository;

/**
 *
 * @author Fabien Renaud
 */
@Repository("paymentMethodDao")
public class PaymentMethodDaoImpl implements PaymentMethodDao {

  public List<PaymentMethod> getPaymentMethods() {
    return (List<PaymentMethod>) Database.getSession().createQuery("from PaymentMethod").list();
  }

  public void savePaymentMethod(PaymentMethod paymentMethod) {
    Database.getSession().save(paymentMethod);
  }

  public void deletePaymentMethod(PaymentMethod paymentMethod) {
    Database.getSession().delete(paymentMethod);
  }

  public void updatePaymentMethod(PaymentMethod paymentMethod) {
    Database.getSession().update(paymentMethod);
  }

  public PaymentMethod getPaymentMethod(int paymentId) {
    return (PaymentMethod)Database.getSession().load(PaymentMethod.class, paymentId);
  }

  public void deletePaymentMethod(int id) {
    Database.getSession().createQuery("delete PaymentMethod as pm where pm.id=" + id).executeUpdate();
  }
}
